package com.gkoudai.open.platform.deserializer;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.gkoudai.open.platform.common.CategoryCommon;

import java.io.IOException;

/**
 * @author wangqi
 * @date 2025-05-12 15:39
 */
public class DataTypeDeserializer extends JsonDeserializer<CategoryCommon.DataType> {

    @Override
    public CategoryCommon.DataType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
        String dataTypeStr = p.getText();
        for (CategoryCommon.DataType value : CategoryCommon.DataType.values()) {
            if (value.getDataType().equals(dataTypeStr)) {
                return value;
            }
        }
        return null;
    }
}